{extend name="layout"/}
{block name="content"}
<div style="text-align: center;margin: 0.6rem;">
    <span style="font-size: 0.5rem">
        员工端登录
    </span>
</div>
<div id="app">
    <van-form @submit="onSubmit">
        <van-field
                v-model="username"
                name="用户名"
                label="用户名"
                placeholder="用户名"
                :rules="[{ required: true, message: '请填写用户名' }]"
        ></van-field>
        <van-field
                v-model="password"
                type="password"
                name="密码"
                label="密码"
                placeholder="密码"
                :rules="[{ required: true, message: '请填写密码' }]"
        ></van-field>
        <div style="margin: 16px;">
            <van-button round block type="info" native-type="submit">
                提 交
            </van-button>
        </div>
    </van-form>
</div>
{/block}
{block name="script"}
<script>
    // 在 #app 标签下渲染一个按钮组件
    new Vue({
        el: '#app',
        data() {
            return {
                username: '',
                password: '',
            };
        },
        methods: {
            onSubmit() {
                axios.post(LOGIN_SUBMIT, {
                    username: this.username,
                    password: this.password
                }).then(function(res) {
                    if(res.data.code == 1) {
                        location.href = res.data.data.url ? res.data.data.url : URL_STAFF_CENTER;
                    }
                    vant.Toast(res.data.msg)
                })
            },
        },
    });
    // 调用函数组件，弹出一个 Toast
    // vant.Toast('提示');
</script>
{/block}